<<<<<<< .mine
var Pagination = function(conf){
	var defaults = { pageSize: 20, page: 1, renderTo: 'body' }, self = this;
	this.conf = {};
	$.extend(this.conf, defaults, conf);

	this.pageSize = this.conf.pageSize;
	this.page = this.conf.page;
	this.container = $(this.conf.renderTo).append(this.getHtml());
	
	this.el = this.container.find('.pagination');
	this.elFrom = this.el.find('.from');
	this.elTo = this.el.find('.to');
	this.elTotal = this.el.find('.total');
	this.elTotalPages = this.el.find('.total-pages');
	
	this.btnPrev = this.el.find('.prev');
	this.btnNext = this.el.find('.next');
	
	this.pageDropdown = new DropDown({ id: this.el.find('.dropdown'), scope: this, action: this.gotoPage });	
	this.el
		.on('click', '.prev:not(.disabled)', $.proxy(this.previousPage, this))
		.on('click', '.next:not(.disabled)', $.proxy(this.nextPage, this));

	// public getters and setters - will be attached to the pagination dom element
		this.el.updatePagination = function(total){ self.update.call(self, total); };
		this.el.resetPagination = function(){ self.reset.call(self); };
		this.el.getPage = function(){ return self.page; };
		this.el.setPage = function(page){ self.page = page; };
		this.el.getPageSize = function(){ return self.pageSize; };
		this.el.setPageSize = function(pageSize){ self.pageSize = pageSize; };
	
	return this.el;
};
Pagination.toString = function(){return 'XWERX Pagination Component';};

Pagination.prototype.getHtml = function(){
	return '<div class="pagination">'+
		'<span class="txt">displaying</span><em class="from">0</em><span class="txt">to</span><em class="to">0</em><span class="txt">of</span><b class="total">0</b><span class="separator">|</span>'+
		'<div class="dropdown"><a class="button button-gray" href="#1"><span class="expander"></span><span class="text">Page 1</span></a><div class="menu"><ul><li><a href="#1">Page 1</a></li></ul></div></div>'+
		'<span class="txt">of</span><b class="total-pages">0</b><span class="separator">|</span><span class="lnk prev">&laquo; prev</span><span class="lnk next">next &raquo;</span>'+
	'</div>';
};


Pagination.prototype.update = function(total){
	var startRec, endRec, i=1, par=[];

	if (typeof total === 'number') this.total = total;
	if (typeof this.total !== 'number') return;
	
	this.totalPages = Math.ceil(this.total/this.pageSize);
	startRec = (this.total > 0 ? ((this.page-1)*this.pageSize)+1 : 0); 
	endRec = startRec + this.pageSize - 1;
	if (endRec>this.total) endRec = this.total;
	
	if (this.totalPages>1){																							// more than 1 -> show dropdown with pages
		for (; i<=this.totalPages; i++) par.push({ id: i, name: 'Page '+i });
		this.pageDropdown.replaceList(par);
	}
	else this.pageDropdown.replaceList([{id:1, name:'Page 1'}]);
	
	
	this.elFrom.text(startRec);
	this.elTo.text(endRec);
	this.elTotal.text(this.total);
	this.elTotalPages.text(this.totalPages);
	this.pageDropdown.setValue(this.page);
	this.btnPrev.toggleClass('disabled', this.page<=1);
	this.btnNext.toggleClass('disabled', this.page>=this.totalPages);

	this.el.page = this.page;
	this.el.pageSize = this.pageSize;
	//this.el.toggle(this.totalPages > 1);
};

Pagination.prototype.reset = function(){ this.page = 1; };

Pagination.prototype.loadPage = function(page){
	this.page = page;
	this.el.page = page;
	this.update();
	this.el.trigger('loadPage', [ page ]);
};
Pagination.prototype.gotoPage = function(page){	if (this.page != page && page >=1 && page <= this.totalPages) this.loadPage(+page); };
Pagination.prototype.previousPage = function(){ this.gotoPage(this.page - 1); };
Pagination.prototype.nextPage = function(){ this.gotoPage(this.page + 1); };

=======
var Pagination = function(conf){
	var defaults = { pageSize: 20, page: 1, renderTo: 'body' }, self = this;
	this.conf = {};
	$.extend(this.conf, defaults, conf);

	this.pageSize = this.conf.pageSize;
	this.page = this.conf.page;
	this.container = $(this.conf.renderTo).append(this.getHtml());
	
	this.el = this.container.find('.pagination');
	this.elFrom = this.el.find('.from');
	this.elTo = this.el.find('.to');
	this.elTotal = this.el.find('.total');
	this.elTotalPages = this.el.find('.total-pages');
	
	this.btnPrev = this.el.find('.prev');
	this.btnNext = this.el.find('.next');
	
	this.pageDropdown = new DropDown({ id: this.el.find('.dropdown'), scope: this, action: this.gotoPage });	
	this.el
		.on('click', '.prev:not(.disabled)', $.proxy(this.previousPage, this))
		.on('click', '.next:not(.disabled)', $.proxy(this.nextPage, this));

	// public getters and setters - will be attached to the pagination dom element
		this.el.updatePagination = function(total){ self.update.call(self, total); };
		this.el.resetPagination = function(){ self.reset.call(self); };
		this.el.getPage = function(){ return self.page; };
		this.el.setPage = function(page){ self.page = page; };
		this.el.getPageSize = function(){ return self.pageSize; };
		this.el.setPageSize = function(pageSize){ self.pageSize = pageSize; };
	
	return this.el;
};
Pagination.toString = function(){return 'XWERX Pagination Component';};

Pagination.prototype.getHtml = function(){
	return '<div class="pagination">'+
		'<span class="txt">displaying</span><em class="from">0</em><span class="txt">to</span><em class="to">0</em><span class="txt">of</span><b class="total">0</b><span class="separator">|</span>'+
		'<div class="dropdown"><a class="button button-gray" href="#1"><span class="expander"></span><span class="text">Page 1</span></a><div class="menu"><ul><li><a href="#1">Page 1</a></li></ul></div></div>'+
		'<span class="txt">of</span><b class="total-pages">0</b><span class="separator">|</span><span class="lnk prev">&laquo; prev</span><span class="lnk next">next &raquo;</span>'+
	'</div>';
};


Pagination.prototype.update = function(total){
	var startRec, endRec, i=1, par=[];

	if (total && typeof total === 'number') this.total = total;
	if (typeof this.total !== 'number') return;
	
	this.totalPages = Math.ceil(this.total/this.pageSize);
	startRec = ((this.page-1)*this.pageSize)+1; 
	endRec = startRec + this.pageSize - 1;
	if (endRec>this.total) endRec = this.total;
	
	if (this.totalPages>1){																							// more than 1 -> show dropdown with pages
		for (; i<=this.totalPages; i++) par.push({ id: i, name: 'Page '+i });
		this.pageDropdown.replaceList(par);
	}
	else this.pageDropdown.replaceList([{id:1, name:'Page 1'}]);
	
	this.elFrom.text(startRec);
	this.elTo.text(endRec);
	this.elTotal.text(this.total);
	this.elTotalPages.text(this.totalPages);
	this.pageDropdown.setValue(this.page);
	this.btnPrev.toggleClass('disabled', this.page<=1);
	this.btnNext.toggleClass('disabled', this.page>=this.totalPages);

	this.el.page = this.page;
	this.el.pageSize = this.pageSize;
	//this.el.toggle(this.totalPages > 1);
};

Pagination.prototype.reset = function(){ this.page = 1; };

Pagination.prototype.loadPage = function(page){
	this.page = page;
	this.el.page = page;
	this.update();
	this.el.trigger('loadPage', [ page ]);
};
Pagination.prototype.gotoPage = function(page){	if (this.page != page && page >=1 && page <= this.totalPages) this.loadPage(+page); };
Pagination.prototype.previousPage = function(){ this.gotoPage(this.page - 1); };
Pagination.prototype.nextPage = function(){ this.gotoPage(this.page + 1); };

>>>>>>> .r59
